package listclick;

import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import com.example.administrator.ac.MainActivity;
import com.example.administrator.ac.MyFragment;
import com.example.administrator.ac.OrderActivity;

import java.util.ArrayList;

import demo.com.administrator.adapter.ListViewAdapter;

/**
 * Created by Administrator on 2017/6/27.
 */

public class OrderList implements AdapterView.OnItemClickListener{
    private ListView unprocesslist;
    private  ListViewAdapter lva;
    ArrayList<String> l;
   public OrderList(ListView unprocesslist){
       this.unprocesslist=unprocesslist;
   }
    public void setUnprocessList() {
        l=new ArrayList<String>();
        l.add("safsfasfds");
        l.add("ttrsfasfds");
        l.add("safs");
        l.add("safs");
        l.add("safs");
        l.add("safs");
        l.add("safs");
        l.add("safs");
        l.add("safs");
        l.add("safs");
        l.add("safs");
        l.add("safsfa442342sfds");
        lva=new ListViewAdapter(l);
        unprocesslist.setAdapter(lva);
        unprocesslist.setOnItemClickListener(this);
    }


    //查找匹配的Item
    public void searchList(String search){
        ArrayList<String> sl=new ArrayList<>();
        for(String u:l){
            if(u.contains(search)){
                sl.add(u);
            }
        }
        lva=new ListViewAdapter(sl);
        unprocesslist.setAdapter(lva);

    }


    //跳转选择的订单界面
    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
       Intent intent=new Intent();
        intent.setClass(MainActivity.mcontext,OrderActivity.class);
       intent.putExtra("orderid",l.get(position));

        MainActivity.mcontext.startActivity(intent);

    }
}
